import java.io.*;
import java.net.*;

public class JClient {
  public static void main(String[] args) throws IOException {
    String hostname = args[0];
    String instruct = args[1];
    Socket commSocket = new Socket(hostname, 9000);

    InputStream in = commSocket.getInputStream();
    OutputStream out = commSocket.getOutputStream();

    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    PrintWriter writer = new PrintWriter(out);

    if(instruct.equals("get")) {
      writer.println("get");
      writer.flush();
      while(true) {
        try {
          String line = reader.readLine();
          if(line == null) break;
          System.out.println(line);
        } catch(Exception e) {
          break;
        }
      }
    } else {
      String message = args[2];
      writer.println("put");
      writer.println(message);
      writer.flush();
    }
  }
}
